<template>
  <el-form
    ref="qmGenForm"
    :model="model"
    :rules="rules"
    :disabled="disabled"
    label-width="80px"
  >
    <el-row>
      <el-col :span="12">
        <el-form-item label="应用标题" prop="appTitle">
          <el-input v-model="model.appTitle" placeholder="请输入标题" />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="应用分类" prop="appCategory">
          <el-select v-model="model.appCategory" placeholder="请选择应用分类">
            <el-option
              v-for="item in controlData.appCategoryDictItems"
              :value="item.code"
              :label="item.name"
              :key="item.code"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="关键词" prop="appKeywords">
          <el-input
            v-model="model.appKeywords"
            placeholder="请输入关键词(多个用逗号分隔)"
          />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="作者" prop="appAuthor">
          <el-input v-model="model.appAuthor" disabled />
        </el-form-item>
      </el-col>
    </el-row>
    <el-form-item label="摘要" prop="appAbstract">
      <el-input
        v-model="model.appAbstract"
        type="textarea"
        placeholder="请输入摘要"
      />
    </el-form-item>
    <el-form-item label="应用描述" prop="appDescribe">
      <editor
        v-model="model.appDescribe"
        :min-height="192"
        :disabled="disabled"
      />
    </el-form-item>
    <el-row>
      <el-col :span="viewModel.pageAction === 'create' ? 24 : 12">
        <el-form-item label="SVN地址" prop="svnUrl">
          <el-input v-model="model.svnUrl" placeholder="请输入SVN地址" />
        </el-form-item>
      </el-col>
      <el-col v-if="viewModel.pageAction !== 'create'" :span="12">
        <el-tooltip
          effect="dark"
          content="自动填充最新版本号"
          placement="top-start"
        >
          <el-form-item label="当前版本" prop="currentVersion">
            <el-input v-model="model.currentVersion" disabled />
          </el-form-item>
        </el-tooltip>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
import Editor from "@/components/Editor";

export default {
  name: "MarketAppCreate",
  props: {
    viewModel: Object,
    model: Object,
    controlData: Object,
    disabled: Boolean,
  },
  components: {
    Editor,
  },
  data() {
    return {
      rules: {
        appTitle: [
          {
            required: true,
            message: "应用标题不能为空",
            trigger: "blur",
          },
        ],
        appCategory: [
          {
            required: true,
            message: "应用分类不能为空",
            trigger: "change",
          },
        ],
        appAbstract: [
          {
            required: true,
            message: "摘要不能为空",
            trigger: "blur",
          },
        ],
      },
    };
  },
};
</script>
